import paramiko
import re

##分析脚本内容
with open('/Users/liwk/py/oratk_web/templates/shell_content/ora_args_tmp.txt', 'r', encoding='utf-8') as f:
    args_value = 'awrdiff'
    file_content_list = f.readlines()
    i = 1
    pattern_command_usage_flag = re.compile(r'^\s*-\s*{}'.format(args_value))
    pattern_multi_line = re.compile(r'^\s*\w+')
    end_command_usage_flag = '##end command usage'
    pattern_end_command_usage_flag = re.compile(r'^{}*'.format(end_command_usage_flag))

    for line in file_content_list:
        if  pattern_end_command_usage_flag.search(line):
            break
        if pattern_command_usage_flag.search(line):
            for line_more in file_content_list[i:]:
                if pattern_end_command_usage_flag.search(line):
                    break
                if pattern_multi_line.search(line_more):
                    line = line + line_more
                else:
                    break
            print(line)
        i = i +1
    print(i)




